var SleekPHP = {
	modules: [], 
	styles: [], 

	run: function () {
		SleekPHP.runModules();
		SleekPHP.runStyles();
	}, 

	runModules: function () {
		for (var module in SleekPHP.modules) {
			// Work out the HTML-ID based on the module-name (RecentArticles == recent-articles)
			var id		= module.replace(/([A-Z])/g, '-$1').toLowerCase();
				id		= id.substring(0, 1) == '-' ? id.substring(1) : id;
			var mod		= jQuery('#' + id);

			// Only run modules that are used and don't run ajax-run-modules
			if ( 
					mod.length && 
					typeof(SleekPHP.modules[module]) != 'undefined' && 
					typeof(SleekPHP.modules[module].run) == 'function' 
			) {

				SleekPHP.modules[module].run(mod);
			}
		}
	}, 

	runStyles: function () {
		for (var style in SleekPHP.styles) {
			if ( 
				typeof(SleekPHP.styles[style]) != 'undefined' && 
				typeof(SleekPHP.styles[style].run) == 'function' 
			) {
				SleekPHP.styles[style].run();
			}
		}
	}
};

$(SleekPHP.run);
